package jinyilw.tools.audio;
import java.net.URL;

public abstract class BaseAudioRenderer
{
	public static final int PLAYING = 1;
	public static final int STOPPED = 2;
	public static final int END_OF_SOUND = 3;
	public static final int ERROR = 4;
	private URL audioFile;
	private boolean loop;
	protected int status = 2;
	protected float volume = 1.0F;

	public BaseAudioRenderer()
	{
	}

	protected abstract void playSound(URL var1);

	protected abstract void replaySound(URL var1);

	protected abstract void stopSound();

	protected void setSoundVolume(float volume)
	{
	}

	public void play(URL file)
	{
		this.status = 1;
		if (this.audioFile == file)
		{
			this.replaySound(this.audioFile);
		} else
		{
			this.audioFile = file;
			this.playSound(this.audioFile);
		}
	}

	public void play()
	{
		this.status = 1;
		this.replaySound(this.audioFile);
	}

	public void stop()
	{
		if (this.audioFile != null && this.status == 1)
		{
			this.status = 2;
			this.stopSound();
		}

	}

	public void setLoop(boolean b)
	{
		this.loop = b;
	}

	public boolean isLoop()
	{
		return this.loop;
	}

	public void setVolume(float v)
	{
		if (v < 0.0F)
		{
			v = 0.0F;
		}

		if (v > 1.0F)
		{
			v = 1.0F;
		}

		if (this.volume != v && this.isVolumeSupported())
		{
			this.volume = v;
			this.setSoundVolume(this.volume);
		}

	}

	public float getVolume()
	{
		return this.volume;
	}

	public boolean isVolumeSupported()
	{
		return true;
	}

	public URL getAudioFile()
	{
		return this.audioFile;
	}

	public int getStatus()
	{
		return this.status;
	}

	public abstract boolean isAvailable();
}